package org.linlinjava.litemall.admin.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.linlinjava.litemall.admin.beans.annotation.LogAnno;
import org.linlinjava.litemall.admin.service.AdminLumiereFormulaSpecificationsService;
import org.linlinjava.litemall.admin.vo.LumiereFormulaSpecificationsVO;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.domain.LumiereFormulaSpecifications;
import org.springframework.web.bind.annotation.*;

@Api(tags = "配方规格管理API")
@RestController
@RequestMapping("admin/formulaSpecifications")
@RequiredArgsConstructor
public class AdminLumiereFormulaSpecificationsController {

    private final AdminLumiereFormulaSpecificationsService adminLumiereFormulaSpecificationsService;

    @ApiOperation("配方规格管理-查询配方规格列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "limit",value = "数量"),
            @ApiImplicitParam(name = "page",value = "当前页"),
    })
    @LogAnno
    @GetMapping("/list")
    public ResponseUtil.Response list(LumiereFormulaSpecifications lumiereFormulaSpecifications,
                                      @RequestParam("limit")Integer limit,
                                      @RequestParam("page")Integer page) {
        return adminLumiereFormulaSpecificationsService.listLumiereFormulaSpecifications(lumiereFormulaSpecifications,page,limit);
    }

    @ApiOperation("配方规格管理-新增配方规格")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "specificationsName",value = "规格名称"),
    })
    @LogAnno
    @PostMapping("/add")
    public ResponseUtil.Response add(@RequestBody LumiereFormulaSpecificationsVO lumiereFormulaSpecificationsVO)  {
        return adminLumiereFormulaSpecificationsService.addLumiereFormulaSpecifications(lumiereFormulaSpecificationsVO);
    }

    @ApiOperation("配方规格管理-编辑配方规格")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "specificationsName",value = "规格名称"),
    })
    @LogAnno
    @PutMapping ("/update")
    public ResponseUtil.Response update(@RequestBody LumiereFormulaSpecifications lumiereFormulaSpecifications)  {
        return adminLumiereFormulaSpecificationsService.updateLumiereFormulaSpecifications(lumiereFormulaSpecifications);
    }

    @ApiOperation("配方规格管理-删除配方规格")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "id"),
    })
    @LogAnno
    @DeleteMapping("/delete")
    public ResponseUtil.Response delete(Integer id)  {
        return adminLumiereFormulaSpecificationsService.deleteLumiereFormulaSpecifications(id);
    }


}
